package 剑指offer;

import org.omg.CORBA.INTERNAL;

import java.util.ArrayList;

/**
 * Created by root on 17-2-27.
 */
public class FindPath {
    ArrayList<TreeNode> arrayList = new ArrayList<>();
    public void DepTraverse(TreeNode treeNode) {

        if (treeNode == null) {
            return;
        }
        arrayList.add(treeNode);
        if (treeNode.right == null && treeNode.left == null ) {
            System.out.println("===========");
            for (TreeNode a : arrayList) {
                System.out.print(a.val + " ");
            }
            System.out.println("===========");
        }
        DepTraverse(treeNode.left);
        if (treeNode.left != null) {
            arrayList.remove(treeNode.left);
        }
        DepTraverse(treeNode.right);
        if (treeNode.right != null) {
            arrayList.remove(treeNode.right);
        }
    }
}
